package com.wyl.pmd.rule.bestpractices;

import com.wyl.pmd.model.SomeException;

public class PreserveStackTrace {

	void good() {
        try{
            Integer.parseInt("a");
        } catch (Exception e) {
        	// 创建异常链的第一种可能性
            throw new SomeException("good_new_exception", e);
        }
        try {
            Integer.parseInt("a");
        } catch (Exception e) {
        	// 创建异常链的第二种可能性
            throw (IllegalStateException)new IllegalStateException().initCause(e);
        }
    }
    void bad() {
        try{
            Integer.parseInt("a");
        } catch (Exception e) {
        	// 异常链路丢失
            throw new SomeException(e.getMessage());
        }
    }
	
}
